#Load CoreSPECT and configuration module
from cplearn.corespect import CorespectModel
from cplearn.corespect.config import CoreSpectConfig
#Initial parameters.
cfg = CoreSpectConfig(
q=40, #Determines neighborhood size for the underlying q-NN graph
r=20, #Neighborhood radius parameter for ascending random walk with FlowRank
core_frac=0.25, #Fraction of points in the top-layer
densify=False, #Densifying different parts of the data to reduce fragmentation
granularity=0.5, #Higher granularity finds more local cores but can lead to missing out on weaker clusters.
resolution=0.5 #Resolution for clustering with Leiden (more clustering methods will be added later)
).configure()
# Run **CoreSPECT**
model = CorespectModel(X, **cfg.unpack()).run(fine_grained=True,propagate=True)
'''
Main components of model:
model.layers_: Containts a list of lists. Each list consists of a subset of indices (between 0 and n-1, where n:= X.shape[0])
The first list corresponds to the indices that form the cores, the subsequent lists contain the outer layers.
model.labels_: n-sized integer array.
If propagate==False: Contains clustering label for the core (model.layers_[0]) indices, -1 in other places.
If propagate==True: Contains clustering label for all the points.
'''